<?php include "../public/header.php";?>
<?php include "../public/header_show.php";?>
<script src='/static/admin/js/common_index.js'></script>
<script src='/static/admin/js/tableList.js'></script>
<style>
    .jingchabut{position: absolute;right: 20px;top: 10px;height: 30px;line-height: 25px;background: #2272eb;color: #fff;width: 90px;border-radius: 6px;}
    .jingchabut:hover{background: #FFFFFF;color: #2272eb;}
    .bbtt{font-size: 16px;margin-top: 15px}
</style>
<body id="xiangqingPage">
<div id="xiangqingBox" style="padding-top: 10px;padding-bottom: 150px" class="layui-form">
    <div style="margin: 10px 0 0 15px">
        <div style="width: 200px;float: left">
            <select id="year" name="year" lay-filter="year">
                <option value="">请选择</option>
            </select>
        </div>
        <div style="width: 200px;float: left">
            <select id="jidu" name="jidu" lay-filter="jidu">
                <option value="">全年</option>
            </select>
        </div>
        <div style="width: 200px;float: left;margin-left: 10px">
            <div id="chanid" class="xmselect_div">
                <div class="xmselect_title">请选择</div>
            </div>
        </div>
        <div style="float: left;margin-left: 15px">
            <button class="laytp-btn laytp-btn-md laytp-btn-primary" id="jingChaButton"><i class="layui-icon layui-icon-search"></i>查询</button>
        </div>
    </div>
    <div style="clear: both"></div>

    <div class="main-container">
        <div class="tongbox tongbox8">
            <div class="tuo">
                <div class="tit">工程承揽总数</div>
                <div class="con" id="enginnum"></div>
            </div>
            <div class="tuo">
                <div class="tit">合同价总额(元)</div>
                <div class="con" id="shimoney"></div>
            </div>
            <div class="tuo">
                <div class="tit">工程结算总额(元)</div>
                <div class="con" id="shijiemoney"></div>
            </div>
            <div class="tuo">
                <div class="tit">开具销项发票总额(元)</div>
                <div class="con" id="piaokaifee"></div>
            </div>
            <div class="tuo">
                <div class="tit">工程回款总额(元)</div>
                <div class="con" id="huihonghuimoney"></div>
            </div>
            <div class="tuo">
                <div class="tit">税款保证金（含利息）收取(元)</div>
                <div class="con" id="koushuifee"></div>
            </div>
            <div class="tuo">
                <div class="tit">劳务分包服务费收取(元)</div>
                <div class="con" id="koufuwufee"></div>
            </div>
            <div class="tuo">
                <div class="tit">劳务分包服务费支出(元)</div>
                <div class="con" id="zhifuwufee"></div>
            </div>
        </div>


        <div class="table-box">
            <div class="layui-row">
                <div class="layui-col-md6">
                    <div class="layui-card-body">
                        <script type="text/html" id="toolbarDemo_chan">
                            <div class="bbtt"><b>工程回款（前10名）排名</b></div>
                        </script>
                        <table id="datalist_chan" lay-filter="datalist_chan"></table>
                    </div>
                </div>
                <div class="layui-col-md6">
                    <div class="layui-card-body">
                        <script type="text/html" id="toolbarDemo_cheng">
                            <div class="bbtt"><b>工程负责人承揽（前10名）排名</b></div>
                        </script>
                        <table id="datalist_cheng" lay-filter="datalist_cheng"></table>
                    </div>
                </div>
                <div class="layui-col-md12">
                    <div class="layui-card-body">
                        <script type="text/html" id="toolbarDemo_jie">
                            <div class="bbtt"><b>借款排名（前10名）汇总表</b></div>
                        </script>
                        <table id="datalist_jie" lay-filter="datalist_jie"></table>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script>
    var public_chanid=0;
    var public_year=0;
    var public_jidu=0;
    var qingci=1;



    layui.use(['form', 'layer', "laytp",'element','dropdown','laypage','table','soulTable'], function() {
        var laypage = layui.laypage, table = layui.table, dropdown = layui.dropdown, form = layui.form,
            soulTable = layui.soulTable, element = layui.element;
        rel_engin_quan();
        rel_engin_quan_chan();
        rel_engin_quan_cheng();
        rel_engin_quan_jie();
        function rel_engin_quan() {
            facade.ajax({url: ask_engin_quan, data:{qingci:qingci,chanid:public_chanid,year:public_year,jidu:public_jidu}}).done(function (res) {
                if (res.code === 2000) {
                    var data = res.data;

                    var year_str = '<option value="">请选择</option>';
                    var year = res.data.year;
                    for (var key in year){
                        if(res.data.is_year == year[key]){
                            year_str += '<option value="'+year[key]+'" selected>'+year[key]+'</option>';
                        }else {
                            year_str += '<option value="'+year[key]+'">'+year[key]+'</option>';
                        }

                    }
                    $("#year").html(year_str);


                    var jidu_str = '<option value="">请选择</option>';
                    var jidu = res.data.jidu;
                    for (var key in jidu){
                        if(res.data.is_jidu == key){
                            jidu_str += '<option value="'+key+'" selected>'+jidu[key]+'</option>';
                        }else {
                            jidu_str += '<option value="'+key+'">'+jidu[key]+'</option>';
                        }

                    }
                    $("#jidu").html(jidu_str);

                    xmselect_dan('chanid', data.chanid, data.is_chanid);



                    if(data.enginnum){
                        $("#enginnum").text(data.enginnum);
                    }else{
                        $("#enginnum").text(0);
                    }

                    if(data.shimoney){
                        $("#shimoney").text(parseFormatNum(data.shimoney));
                    }else{
                        $("#shimoney").text(0);
                    }

                    if(data.shijiemoney){
                        $("#shijiemoney").text(parseFormatNum(data.shijiemoney));
                    }else{
                        $("#shijiemoney").text(0);
                    }

                    if(data.piaokaifee){
                        $("#piaokaifee").text(parseFormatNum(data.piaokaifee));
                    }else{
                        $("#piaokaifee").text(0);
                    }

                    if(data.huihonghuimoney){
                        $("#huihonghuimoney").text(parseFormatNum(data.huihonghuimoney));
                    }else{
                        $("#huihonghuimoney").text(0);
                    }

                    if(data.koushuifee){
                        $("#koushuifee").text(parseFormatNum(data.koushuifee));
                    }else{
                        $("#koushuifee").text(0);
                    }

                    if(data.koufuwufee){
                        $("#koufuwufee").text(parseFormatNum(data.koufuwufee));
                    }else{
                        $("#koufuwufee").text(0);
                    }

                    if(data.zhifuwufee){
                        $("#zhifuwufee").text(parseFormatNum(data.zhifuwufee));
                    }else{
                        $("#zhifuwufee").text(0);
                    }



                    render_from();
                }
            });
        }
        $("#jingChaButton").click(function () {
            qingci++;
            public_chanid = $("input[name=chanid]").val() || 0;
            public_year = $("#year").val() || 0;
            public_jidu = $("#jidu").val() || 0;

            rel_engin_quan();
            rel_engin_quan_chan();
            rel_engin_quan_cheng();
            rel_engin_quan_jie();
        });







        function rel_engin_quan_chan() {
            var mytable = table.render({
                elem: "#datalist_chan",id: "datalist_chan"
                ,url: facade.url(ask_engin_quan_chan),where: {qingci:qingci,year:public_year,jidu:public_jidu}, page: true
                ,soulSort: TabInit.soulSort,method: TabInit.method, toolbar: '#toolbarDemo_chan', overflow: TabInit.overflow
                ,defaultToolbar: ['','',''],filter: TabInit.filter
                ,request: TabInit.request,response: TabInit.response,contextmenu:get_table_contextmenu(soulTable)
                ,text: TabInit.text,totalRow: true
                ,parseData: function (res) {
                    render_from();
                    return {
                        "code": res.code,
                        "msg": res.message,
                        "count": res.data.total,
                        "data": res.data.data
                    };
                }
                , cols: [[
                    {type:'numbers',title:'序号',totalRowText: '合计'}
                    ,{field:'enginname',title:'工程名称'}
                    ,{field:'gofuer',title:'工程负责人'}
                    ,{field:'countfee',title:'工程回款金额(元)',totalRow: true,templet: function(d){return parseFormatNum(d.countfee);}}
                ]]
                , done: function (res) {
                    $(".layui-table-page").remove()
                    soulTable.render(this);
                }
            });
        }
        function rel_engin_quan_cheng() {
            var mytable = table.render({
                elem: "#datalist_cheng",id: "datalist_cheng"
                ,url: facade.url(ask_engin_quan_cheng),where: {qingci:qingci,year:public_year,jidu:public_jidu}, page: true
                ,soulSort: TabInit.soulSort,method: TabInit.method, toolbar: '#toolbarDemo_cheng', overflow: TabInit.overflow
                ,defaultToolbar: ['','',''],filter: TabInit.filter
                ,request: TabInit.request,response: TabInit.response,contextmenu:get_table_contextmenu(soulTable)
                ,text: TabInit.text,totalRow: true
                ,parseData: function (res) {
                    render_from();
                    return {
                        "code": res.code,
                        "msg": res.message,
                        "count": res.data.total,
                        "data": res.data.data
                    };
                }
                , cols: [[
                    {type:'numbers',title:'序号',totalRowText: '合计'}
                    ,{field:'gofuer',title:'工程负责人'}
                    ,{field:'nums',title:'承揽项目数'}
                    ,{field:'countfee',title:'中标金额(元)',totalRow: true,templet: function(d){return parseFormatNum(d.countfee);}}
                ]]
                , done: function (res) {
                    $(".layui-table-page").remove()
                    soulTable.render(this);
                }
            });
        }
        function rel_engin_quan_jie() {
            var mytable = table.render({
                elem: "#datalist_jie",id: "datalist_jie"
                ,url: facade.url(ask_engin_quan_jie),where: {qingci:qingci,year:public_year,jidu:public_jidu}, page: true
                ,soulSort: TabInit.soulSort,method: TabInit.method, toolbar: '#toolbarDemo_jie', overflow: TabInit.overflow
                ,defaultToolbar: ['','',''],filter: TabInit.filter
                ,request: TabInit.request,response: TabInit.response,contextmenu:get_table_contextmenu(soulTable)
                ,text: TabInit.text,totalRow: true
                ,parseData: function (res) {
                    render_from();
                    return {
                        "code": res.code,
                        "msg": res.message,
                        "count": res.data.total,
                        "data": res.data.data
                    };
                }
                , cols: [[
                    {type:'numbers',title:'序号',totalRowText: '合计'}
                    ,{field:'jieer',title:'姓名',templet: function(d){
                            return '<span class="colorlan" onclick="openNavPage(\'借款台账\',\'hou_jie_tai/index.php?jieer='+encodeURI(d.jieer)+'\')">'+d.jieer+'</span>';
                        }}
                    ,{field:'countfee',title:'合同借款金额(元)',totalRow: true,templet: function(d){return parseFormatNum(d.countfee);}}
                    ,{field:'yinghuanbenfee',title:'放款到账金额(元)',totalRow: true,templet: function(d){return parseFormatNum(d.yinghuanbenfee);}}
                    ,{field:'yihuanbenfee',title:'已还款金额(元)',totalRow: true,templet: function(d){return parseFormatNum(d.yihuanbenfee);}}
                    ,{field:'yihuanlifee',title:'已收取利息(元)',totalRow: true,templet: function(d){return parseFormatNum(d.yihuanlifee);}}
                    ,{field:'daihuanbenfee',title:'未偿还本金(元)',totalRow: true,templet: function(d){return parseFormatNum(d.daihuanbenfee);}}
                ]]
                , done: function (res) {
                    $(".layui-table-page").remove()
                    soulTable.render(this);
                }
            });
        }



    })









</script>
</body>
</html>




